<template>
	<view>
		<view class="topImage flx2">
			<image src="/static/login/u19.png"></image>
		</view>
		<view>
			<view>
				<view class="styleHeader flx">
					<view :class="{styleHeader_left:true, Selected:Iselected == true}" @click="Iselected = !Iselected">
						账号登录</view>
					<view :class="{styleHeader_right:true, Selected:Iselected == false}"
						@click="Iselected = !Iselected">手机号验证登录</view>
				</view>
				<!-- 登录密码输入框 -->
				<view v-if="Iselected == true">
					<view class="inputStyle flx1">
						<view class="inputStyle_image">
							<image src="/static/login/u25.png"></image>
						</view>
						<view class="inputStyle_text">
							<input
								style="border:none; width: 70%; height: 100%; color: #fff; margin-left: 20rpx; font-size: 25rpx;"
								placeholder="用户名" placeholder-class="pcs" v-model="username" />
						</view>
					</view>
					<view class="inputStyle flx">
						<view class="flx1">
							<view class="inputStyle_image">
								<image src="/static/login/u29.png"></image>
							</view>
							<view class="inputStyle_text">
								<input :type="typetext"
									style="border:none; width: 100%; height: 100%; color: #fff; margin-left: 20rpx; font-size: 25rpx; background-color:#3e9aff;"
									placeholder="密码" placeholder-class="pcs" v-model="password" />
							</view>
						</view>
						<view class="flxAlign" @click="typet">
							<image style="width: 40rpx; height: 40rpx;" src="/static/login/u39.png"></image>
						</view>
					</view>
					<view
						style="width: 85%; font-size:28rpx ; margin:0 auto; margin-top:20rpx; text-align: end; color: #e4e4e4;">
						忘记密码</view>
				</view>
				<!-- 手机验证码 -->
				<view v-else>
					<view class="inputStyle flx1">
						<view class="inputStyle_image">
							<image src="/static/login/u25.png"></image>
						</view>
						<view class="inputStyle_text">
							<input
								style="border:none; width: 70%; height: 100%; color: #fff; margin-left: 20rpx; font-size: 25rpx;"
								placeholder="用户名" placeholder-class="pcs" v-model="username" />
						</view>
					</view>
					<view class="inputStyle flx">
						<view class="flx1">
							<view class="inputStyle_image">
								<image src="/static/login/u29.png"></image>
							</view>
							<view class="inputStyle_text">
								<input
									style="border:none; width: 100%; height: 100%; color: #fff; margin-left: 20rpx; font-size: 25rpx;"
									placeholder="验证码" placeholder-class="pcs" :disabled="Disable" v-model="yzm" />
							</view>
						</view>
						<view class="flxAlign" style="width: 30%;">
							<view class="buttom" @click="countdown">
								{{buttontext}}
							</view>
						</view>

					</view>
					<!-- <view style="width: 85%; font-size:28rpx ; margin:0 auto; margin-top:20rpx; text-align: end; color: #e4e4e4;">忘记密码</view> -->
				</view>
			</view>
			<view class="bottomStyle" @click="login">登录</view>
			<view class="usertexts">还没有账号？<span class="ljzc" @click='zhuce'>立即注册</span></view>
				<u-picker :show="showone" :columns="columns" @confirm='confirm' :closeOnClickOverlay='true' @cancel='close' @close='close'></u-picker>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				columns: [
				    ['我是患者','我是医生']
				],
				showone: false,
				buttontext: '获取验证码',
				Iselected: true,
				typetext: 'password',
				username: '',
				password: '',
				yzm: '',
				number: 60,
				Disable: false

			}
		},
		methods: {
			close(){
				this.showone = false
			},
			countdown() {
				
				if(this.Disable == false){
					this.Disable = true
					let time = setInterval(() => {
						this.number--
						this.buttontext = `${this.number}秒后重新获取`
						if (this.number == 0) {
							this.codetext = '获取验证码'
							this.Disable = false
							clearInterval(time)
						}
					}, 1000)
				}
				
			},
			typet() {
				console.log('123');
				if (this.typetext == 'password') {
					this.typetext = 'text'
				} else {
					this.typetext = 'password'
				}
			},
			zhuce(){
				this.showone = true
				
			},
			confirm(index){
				console.log(index);
				if(index.indexs[0] == 0){
					uni.navigateTo({
						url:'/pages/login/register'
					})
				}else if(index.indexs[0] == 1){
					uni.navigateTo({
						url:'/pages/login/doctorRegister'
					})
				}
			
			},
			login(){
				if(this.username == 'admin' && this.password != ''){
					uni.setStorageSync('number', 1)
					uni.switchTab({
						url:'/pages/index/index_index?number=' + '1'
					})
				}else if(this.username == 'user' && this.password != ''){
					uni.setStorageSync('number', 2)
					uni.switchTab({
						url:'/pages/index/index_index?number=' + '2'
					})
					
				}else{
					uni.$u.toast('账号密码有误！');
				}
				
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #3e9aff;
	}

	.topImage {
		width: 100%;
		margin-top: 150rpx;

		image {
			width: 450rpx;
			height: 350rpx;
		}
	}

	.styleHeader {
		width: 90%;
		margin: 0 auto;
		margin-top: 30rpx;

		.styleHeader_left {
			width: 50%;
			text-align: center;
			color: #fff;
			font-size: 25rpx;
			line-height: 80rpx;
		}

		.styleHeader_right {
			width: 50%;
			text-align: center;
			color: #fff;
			font-size: 25rpx;
			line-height: 80rpx;
		}

		.Selected {
			border-bottom: 8rpx #72a9e2 solid;
		}
	}

	.inputStyle {
		width: 80%;
		margin: 0 auto;
		border-bottom: #fff 1rpx solid;
		padding: 10rpx;
		margin-top: 40rpx;

		.inputStyle_image {
			width: 65rpx;
			height: 65rpx;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.inputStyle_text {
			.pcs {
				color: #fff;
			}
		}

		.buttom {
			width: 100%;
			height: 45rpx;
			background-color: #24cafa;
			border-radius: 10rpx;
			text-align: center;
			color: #fff;
			font-size: 25rpx;
			line-height: 45rpx;
		}
	}

	.bottomStyle {
		width: 80%;
		margin: 0 auto;
		background-color: #24cafa;
		height: 80rpx;
		border-radius: 35rpx;
		margin-top: 30rpx;
		text-align: center;
		line-height: 80rpx;
		font-size: 27rpx;
		letter-spacing: 2rpx;
		color: #fff;
	}

	.usertexts {
		width: 80%;
		margin: 0 auto;
		font-size: 25rpx;
		color: #e4e4e4;
		text-align: center;
		margin-top: 40rpx;

		span {
			color: #3333ff;
		}
	}
</style>